package com.banmao.snake_client;

import com.banmao.snake_client.netty.client.ClientService;
import com.banmao.snake_core.util.ResourceUtil;
//import com.banmao.snake_core.util.SpringContextUtil;
import io.netty.channel.Channel;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public class FXMain extends Application {

    @Override
    public void start(Stage stage) throws IOException {
        // 预加载 Beans
        //log.info("Application preStart {}...", SpringContextUtil.preload());

        FXMLLoader fxmlLoader = new FXMLLoader(ResourceUtil.getResource("/view/indexScene.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        stage.setTitle("Hello! 贪吃蛇 -- By banmao");
        stage.setScene(scene);
        stage.show();
    }

    @Override
    public void stop() throws Exception {
        log.info("Application stop...");
        // 关闭channel
        ClientService.close();
    }

    public static void main(String[] args) {
        launch();
    }

}
